package com.springmvc.netty;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.springmvc.netty.server.IServer;

/**
 * 异步启动server
 * @ClassName: ThreadServer 
 * @author wangruchao
 * @date 2017年12月13日 下午2:18:04
 */
public class ThreadServer extends Thread {

	private static final Logger	LOGGER = LoggerFactory.getLogger(ThreadServer.class);

	IServer						server;

	int							port;

	public ThreadServer() {

	}

	public ThreadServer(int port, IServer server) {
		this.port = port;
		this.server = server;
	}

	@Override
	public void run() {
		long time = System.currentTimeMillis();
		LOGGER.info("异步启动ThreadServer" + time);
		try {
			server.serverStart(port);
		} catch (Exception e) {
			e.printStackTrace();
			LOGGER.error("异步启动ThreadServer异常" + e);
		}
		LOGGER.info("异步启动ThreadServer" + (System.currentTimeMillis() - time));
	}

}